<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: pink;
            padding: 10px;
            border: 10px solid #ccc;
            overflow: auto;
        }
    </style>
</head>
<body>
    <div>11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</div>
    <script>
        var div  = document.querySelector('div')
        // 都是内容加内边距的大小，scroll包含实际内容大小
        div.addEventListener('scroll',function(){
            // 被滚动条卷去的内容大小
            console.log(div.scrollLeft);
            
        })
        console.log(
            
            div.scrollWidth,
            div.clientWidth
        );
        
    </script>
</body>
</html>